package com.yjhb.android.sbz.adapter;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.yjhb.android.sbz.R;
import com.yjhb.android.sbz.entity.ReputationDetailed;
import com.jojo.android.zxlib.base.BaseRecyclerAdapter;
import com.jojo.android.zxlib.tool.ZxLogTool;
import com.jojo.android.zxlib.tool.ZxTimeTool;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 创建者 zx
 * 创建时间 2021/3/1 16:54
 */
public class ReputationDetailedAdapter extends BaseRecyclerAdapter<ReputationDetailedAdapter.Holder, ReputationDetailed> {
    private final String TAG = "ReputationDetailedAdapter";


    public ReputationDetailedAdapter(Context context) {
        super(context);
    }

    @Override
    protected Holder getHolder(View v) {
        return new Holder(v);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.item_reputation_detailed;
    }


    @Override
    public void onBindViewHolder(@NonNull Holder holder, int position) {
        try {
            ReputationDetailed entity = data.get(position);
            holder.remarkTv.setText(""+entity.getRemark());
            holder.dateTv.setText(ZxTimeTool.getDate(entity.getCreateTime().getTime(), "yyyy-MM-dd HH:mm"));
            if (entity.getType() == 0) {
                holder.valueTv.setTextColor(context.getResources().getColor(R.color.green_pass));
                holder.valueTv.setText("-" + entity.getNum() + "积分");
            } else {
                holder.valueTv.setTextColor(context.getResources().getColor(R.color.red_4040));
                holder.valueTv.setText("+" + entity.getNum() + "积分");
            }
        } catch (Exception e) {
            ZxLogTool.err(e);
        }

    }

    class Holder extends RecyclerView.ViewHolder {
        @BindView(R.id.remark_tv)
        TextView remarkTv;
        @BindView(R.id.date_tv)
        TextView dateTv;
        @BindView(R.id.value_tv)
        TextView valueTv;

        public Holder(@NonNull View itemView) {
            super(itemView);
            ButterKnife.bind(this,itemView);
        }
    }

}
